package main

func main() {

}

func hasCycle(head *ListNode) bool {

	if head == nil || head.Next == nil {
		return false
	}

	m := make(map[*ListNode]int)
	for head.Next != nil {
		if _, ok := m[head]; ok {
			return true
		}

		m[head] = 1
		head = head.Next
	}

	return false
}

type ListNode struct {
	Val  int
	Next *ListNode
}
